﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GravityMode :MonoBehaviour
{
    public static GravityMode instance;//单例模拟重力
    private float gravity = 9.8f;//重力大小
    float yValue;//Y轴的大小
    private void Awake()
    {
        if (instance == null) {
            instance = this;
        }
    }
    /// <summary>
    /// 模拟游戏中重力效果,放到Update（所有控制）最前面
    /// </summary>
    /// <param name="thisObject">需要对（thisObject）施加重力</param>
    public void SimulatedGravity(Transform thisObject)
    {
        yValue = thisObject.position.y - gravity / 1000;
        thisObject.position = new Vector3(thisObject.position.x, yValue, 0);
    }
}
